package com.zkt.recommend.infra.rpc;

import com.zkt.recommend.infra.basic.entity.SubjectInfo;
import com.zkt.recommend.infra.convert.SubjectDTOConverter;
import com.zkt.recommend.infra.convert.SubjectLabelDTOConverter;
import com.zkt.recommend.infra.entity.SubjectLabelInfo;
import com.zkt.recommend.infra.entity.SubjectUserRecord;
import com.zkt.subject.api.SubjectFeignService;
import com.zkt.subject.common.entity.Result;
import com.zkt.subject.entity.SubjectInfoDTO;
import com.zkt.subject.entity.SubjectLabelDTO;
import com.zkt.subject.entity.SubjectUserRecordDTO;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author 赵开泰
 * @program jc-club
 * @date 2025/3/28
 * @description 题目相关服务调用
 **/

@Component
public class SubjectRPC {
	
	@Resource
	private SubjectFeignService subjectFeignService;
	
	public List<SubjectLabelInfo> getUserLabels(String username) {
		Result<List<SubjectLabelDTO>> result = subjectFeignService.getUserLabels(username);
		
		return SubjectLabelDTOConverter.INSTANCE.convertDtoToInfoList(result.getData());
	}
	
	public List<SubjectLabelInfo> getLabelsByIds(List<Long> labelIds) {
		Result<List<SubjectLabelDTO>> result = subjectFeignService.queryLabelByIds(labelIds);
		
		return SubjectLabelDTOConverter.INSTANCE.convertDtoToInfoList(result.getData());
	}
	
	public List<SubjectInfoDTO> getSubjectsByIds(List<Long> subjectIds) {
		Result<List<SubjectInfoDTO>> result = subjectFeignService.querySubjectInfoByIds(subjectIds);
		
		return result.getData();
	}
	
	public List<SubjectInfoDTO> getSubjectsByLabelIds(List<Long> labelIds) {
		Result<List<SubjectInfoDTO>> result = subjectFeignService.querySubjectInfoByLabelIds(labelIds);
		
		return result.getData();
	}
	
	public List<SubjectUserRecord> getAllUserRecord(SubjectUserRecordDTO subjectUserRecordDTO) {
		Result<List<SubjectUserRecordDTO>> result = subjectFeignService.getAllSubjectUserRecord(subjectUserRecordDTO);
		
		return SubjectDTOConverter.INSTANCE.convertDtoToUserRecordList(result.getData());
	}
}